package cn.edu.nhic.nhcarsb.controller;

import cn.edu.nhic.nhcarsb.entity.R;
import cn.edu.nhic.nhcarsb.entity.Users;
import cn.edu.nhic.nhcarsb.service.UsersService;
import cn.edu.nhic.nhcarsb.utils.JwtUtils;
import org.apache.catalina.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("/userCenter")
public class UserCenterController extends BaseController {
    @Autowired
    private UsersService usersService;
    @GetMapping("/info")
    public R info(HttpServletRequest request){
        String token = request.getHeader("token");
        Integer uid = JwtUtils.verifyUserTokenAndGetId(token);
        Users users = usersService.getById(uid);
        users.setUpwd("");
        return R.success(users);
    }
}
